<?php  
namespace kakugyou\toolkit_update_url;s

class ControllerToolSetUpdateUrl extends Controller {
	public function index() {
		$this->load_language('toolset/update_url');

		$this->document->setTitle($this->language->get('heading_title'));
		
		$this->data['breadcrumbs'] = array();

   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->language->get('text_home'),
			'href'      => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
      		'separator' => false
   		);

   		
   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->language->get('heading_title'),
			'href'      => $this->url->link('toolset/update_url', 'token=' . $this->session->data['token'] , 'SSL'),
      		'separator' => $this->language->get('text_breadcrumb_separator')
   		);
	
   		if (isset($this->session->data['success'])) {
			$this->data['success'] = $this->session->data['success'];
		
			unset($this->session->data['success']);
		} else {
			$this->data['success'] = '';
		}
		$this->data['action'] = HTTPS_SERVER . 'index.php?route=toolset/update_url/update&token=' . $this->session->data['token'];


        $this->template = 'toolset/update_url.tpl';
        $this->id = 'content';
        $this->layout = 'layout/default';
        $this->render();
	}
	
	
	public function update() {
        $this->load_language('toolset/update_url');

		$urls=array();
		
		$this->load->model('toolset/update_url');

		if (($this->request->server['REQUEST_METHOD'] == 'POST')) {
			$this->model_toolset_update_url->batchUpdate($this->request->post);
		}

		$this->session->data['success'] = sprintf($this->language->get('text_success'),$this->language->get('heading_title'));
		
		$this->redirect($this->url->link('toolset/update_url', 'token=' . $this->session->data['token'] , 'SSL'));
	}
}
?>